<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8" >
    <meta http-equiv="X-UA-Compatible" content="IE=11,IE=10,IE=9,IE=8" >
    <meta name="baidu-site-verification" content="dIcXMeY8Ya" />
    
    <title>Spring-AOP | 即将拥有人鱼线丶</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" >
    <meta name="keywords" content="FutaoSmile, 前端, Web, 付韬, 个人博客" >
    <meta name="description" content="付韬FutaoSmile" >

    
    <link rel="alternative" href="/atom.xml" title="即将拥有人鱼线丶" type="application/atom+xml" >
    
    
    <link rel="shortcut icon" href="/coder957/coder957/favicon.ico" >
    
    <link rel="stylesheet" href="/coder957/css/style.css">
    <!--[if lt IE 9]>
    <script src="/coder957/js/html5.js"></script>
    <![endif]-->
    
<script>
    var _hmt = _hmt || [];
    (function() {
        var hm = document.createElement("script");
        hm.src = "//hm.baidu.com/hm.js?fd459238242776d173cdc64918fb32f2";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
</script>


</head>

<body class="home">
    <!--[if lt IE 9]>
    <div class="browsehappy">
        当前网页 <strong>不支持</strong>
        你正在使用的浏览器. 为了正常的访问, 请 <a href="http://browsehappy.com/">升级你的浏览器</a>.
    </div>
    <![endif]-->

    <!-- 博客头部 -->
    <header class="header">
    <section class="container header-main">
        <div class="logo">
            <a href="/coder957/">
                <div class="cover">
                    <span class="name">即将拥有人鱼线丶</span>
                    <span class="description">FutaoSmile</span>
                </div>
            </a>
        </div>
        <div class="dropnav icon-paragraph-justify" id="JELON__btnDropNav"></div>
        <ul class="menu hidden" id="JELON__menu">
            
                <li rel="/coder957/2017/10/13/AOP/index.html" class="item ">
                    <a href="/coder957/" title="首页" class="icon-home">&nbsp;首页</a>
                </li>
                
                <li rel="/coder957/2017/10/13/AOP/index.html" class="item ">
                    <a href="/coder957/lab/" title="实验室" class="icon-lab">&nbsp;实验室</a>
                </li>
                
                <li rel="/coder957/2017/10/13/AOP/index.html" class="item ">
                    <a href="/coder957/about/" title="关于" class="icon-about">&nbsp;关于</a>
                </li>
                
                <li rel="/coder957/2017/10/13/AOP/index.html" class="item ">
                    <a href="/coder957/comment/" title="留言" class="icon-comment">&nbsp;留言</a>
                </li>
                
        </ul>
        <div class="profile clearfix">
            <div class="feeds fl">
                
                    
                        <p class="links">
                            
                                <a href="https://github.com/FutaoSmile" target="_blank">
                                    Github
                                </a>
                                |
                                    
                                        
                                <a href="http://www.jianshu.com/u/9e2e579df7dd" target="_blank">
                                    简书
                                </a>
                                
                                        
                        </p>
                        <p class="sns">
                            
                                <a href="http://weibo.com/u/2379076265?refer_flag=1001030001_&amp;nick=FutaoSmile%E4%B8%B6" class="sinaweibo" target="_blank"><b>■</b> 新浪微博</a>
                                
                                <a href="https://gitee.com/FutaoSmile" class="qqweibo" target="_blank"><b>■</b> 码云</a>
                                
                                    <!-- <a href="javascript: void(0);" class="wechat">
                        <b>■</b>
                        公众号
                        <span class="popover">
                            <img src="/coder957/img/wechat_mp.jpg" width="120" height="120" alt="我的微信订阅号">
                            <i class="arrow"></i>
                        </span>
                    </a> -->
                        </p>
                        
            </div>
            <div class="avatar fr">
                <img src="/coder957/img/head.png" alt="avatar" title="Jelon">
            </div>
        </div>
    </section>
</header>

    <!-- 博客正文 -->
    <div class="container body clearfix">
        <section class="content">
            <div class="content-main widget">
                <!-- 文章页 -->
<!-- 文章 -->
<article class="post article">
    <header class="text-center">
        <h3 class="post-title"><span>Spring-AOP</span></h3>
    </header>
    <p class="post-meta text-center">
        FutaoSmile丶 发表于
            <time datetime="2017-10-13T08:40:26.385Z">2017-10-13</time>
    </p>
    <div class="post-content">
        <p>des…</p>
<p>1.概念介绍<br>2.前置通知–MethodBeforeAdvice<br>3.后置通知–AfterReturningAdvice<br>4.环绕通知–MethodInterceptor<br>5.异常通知–ExceptionAdvice<br>7.方法名匹配切入点顾问<br>8.默认Advisor自动代理生成器<br>9.Bean名称自动代理生成器</p>
<a id="more"></a>
<p>aop:面向切面编程，可热插拔<br>aop的实现：动态代理模式</p>
<h3 id="概念"><a href="#概念" class="headerlink" title="概念"></a>概念</h3><p><strong>1. 切面(Aspect)</strong><br>泛指交叉业务逻辑，如事务，日志等。常用的切面有<strong>通知</strong>和<strong>顾问</strong>，<strong>实际上就是对主业务逻辑的一种增强</strong></p>
<p><strong>2. 织入(Weaving)</strong><br>织入是将切面代码插入到目标对象的过程</p>
<p><strong>3. 连接点(JoinPonint)</strong><br>连接点是指可以被切面织入的方法，通常业务接口中的方法都是连接点。</p>
<p><strong>4. 切入点(Pointcut)</strong><br>切入点是指切面具体织入的方法，比如一个类中，doSome()将被增强，而doOther()不被增强，则doSome()为切入点，doOther()只是连接点,<em>被标记为final的方法是不能作为连接点与切入点的，因为最终的是不能被修改的，不能被增强的。</em></p>
<p><strong>5. 目标对象(Target)</strong><br>目标对象是指要被增强的对象，即包含主业务逻辑的类的对象，若ServiceImpl类的对象被增强，则该类被称为目标类，该类的对象被称为目标对象。</p>
<p><strong>6. 通知(Advice)</strong><br>通知是切面的一种实现，可以完成简单织入功能，通知定义了增强代码到目标代码的时间点，是目标方法执行之前执行，还是之后执行，通知类型不同，切入时间不同。<br><strong>切入点定义切入的位置，通知定义切入的时间。</strong></p>
<p><strong>7. 顾问(Advisor)</strong><br>顾问是切面的另一种实现，能够将通知以更复杂的方式织入到目标对象中，是将通知包装为更复杂的装配器。可以控制到以哪个连接点作为切入点，通知只能控制织入时间，不能控制到切入点。<br>可以控制切入的位置，选择增强哪个连接点，不增强哪个连接点。<br><strong>即：顾问既能指定切入时间也能指定切入点。</strong></p>
<hr>
<h1 id="通知"><a href="#通知" class="headerlink" title="通知"></a>通知</h1><p><strong>pom</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div></pre></td><td class="code"><pre><div class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</div><div class="line">&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;</div><div class="line">         xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</div><div class="line">         xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;</div><div class="line">    &lt;parent&gt;</div><div class="line">        &lt;artifactId&gt;spring4&lt;/artifactId&gt;</div><div class="line">        &lt;groupId&gt;com.bjxl&lt;/groupId&gt;</div><div class="line">        &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;</div><div class="line">    &lt;/parent&gt;</div><div class="line">    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;</div><div class="line"></div><div class="line">    &lt;artifactId&gt;aop&lt;/artifactId&gt;</div><div class="line"></div><div class="line">    &lt;dependencies&gt;</div><div class="line">        &lt;dependency&gt;</div><div class="line">            &lt;groupId&gt;org.springframework&lt;/groupId&gt;</div><div class="line">            &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;</div><div class="line">        &lt;/dependency&gt;</div><div class="line">        &lt;dependency&gt;</div><div class="line">            &lt;groupId&gt;org.springframework&lt;/groupId&gt;</div><div class="line">            &lt;artifactId&gt;spring-core&lt;/artifactId&gt;</div><div class="line">        &lt;/dependency&gt;</div><div class="line">        &lt;dependency&gt;</div><div class="line">            &lt;groupId&gt;com.google.code.gson&lt;/groupId&gt;</div><div class="line">            &lt;artifactId&gt;gson&lt;/artifactId&gt;</div><div class="line">        &lt;/dependency&gt;</div><div class="line">        &lt;dependency&gt;</div><div class="line">            &lt;groupId&gt;org.springframework&lt;/groupId&gt;</div><div class="line">            &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;</div><div class="line">        &lt;/dependency&gt;</div><div class="line">        &lt;dependency&gt;</div><div class="line">            &lt;groupId&gt;org.springframework&lt;/groupId&gt;</div><div class="line">            &lt;artifactId&gt;spring-context&lt;/artifactId&gt;</div><div class="line">        &lt;/dependency&gt;</div><div class="line">        &lt;dependency&gt;</div><div class="line">            &lt;groupId&gt;org.springframework&lt;/groupId&gt;</div><div class="line">            &lt;artifactId&gt;spring-expression&lt;/artifactId&gt;</div><div class="line">        &lt;/dependency&gt;</div><div class="line"></div><div class="line"></div><div class="line">        &lt;!--AOP联盟规范--&gt;</div><div class="line">        &lt;dependency&gt;</div><div class="line">            &lt;groupId&gt;aopalliance&lt;/groupId&gt;</div><div class="line">            &lt;artifactId&gt;aopalliance&lt;/artifactId&gt;</div><div class="line">            &lt;version&gt;1.0&lt;/version&gt;</div><div class="line">        &lt;/dependency&gt;</div><div class="line">        &lt;dependency&gt;</div><div class="line">            &lt;groupId&gt;org.springframework&lt;/groupId&gt;</div><div class="line">            &lt;artifactId&gt;spring-context&lt;/artifactId&gt;</div><div class="line">        &lt;/dependency&gt;</div><div class="line">        &lt;dependency&gt;</div><div class="line">            &lt;groupId&gt;org.springframework&lt;/groupId&gt;</div><div class="line">            &lt;artifactId&gt;spring-test&lt;/artifactId&gt;</div><div class="line">            &lt;version&gt;4.2.5.RELEASE&lt;/version&gt;</div><div class="line">        &lt;/dependency&gt;</div><div class="line">        &lt;dependency&gt;</div><div class="line">            &lt;groupId&gt;junit&lt;/groupId&gt;</div><div class="line">            &lt;artifactId&gt;junit&lt;/artifactId&gt;</div><div class="line">            &lt;scope&gt;test&lt;/scope&gt;</div><div class="line">        &lt;/dependency&gt;</div><div class="line">    &lt;/dependencies&gt;</div><div class="line"></div><div class="line">&lt;/project&gt;</div></pre></td></tr></table></figure></p>
<p><strong>Interface</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">package `interface`</div><div class="line"></div><div class="line">/**</div><div class="line"> * Created by futao on 2017/10/13.</div><div class="line"> */</div><div class="line">interface ISomeService &#123;</div><div class="line"></div><div class="line">    fun doFirst()</div><div class="line">    fun doSecond()</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p><strong>Impl</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div></pre></td><td class="code"><pre><div class="line">package Impl</div><div class="line"></div><div class="line">import `interface`.ISomeService</div><div class="line">import org.springframework.stereotype.Service</div><div class="line"></div><div class="line">/**</div><div class="line"> * Created by futao on 2017/10/13.</div><div class="line"> */</div><div class="line">@Service</div><div class="line">class SomeServiceImpl:ISomeService &#123;</div><div class="line">    override fun doFirst()&#123;</div><div class="line">        println(&quot;主业务逻辑代码 -- do first&quot;)</div><div class="line">    &#125;</div><div class="line">    override fun doSecond()&#123;</div><div class="line">        println(&quot;主业务逻辑代码 -- do second&quot;)</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p><strong>AOP–前置通知–MethodBeforeAdvice</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div></pre></td><td class="code"><pre><div class="line">package AOP</div><div class="line"></div><div class="line">import org.springframework.aop.MethodBeforeAdvice</div><div class="line">import java.lang.reflect.Method</div><div class="line"></div><div class="line">/**</div><div class="line"> * @author futao</div><div class="line"> * Created on 2017/10/16 - 10:57.</div><div class="line"> */</div><div class="line">class MyMethodBeforeAdvice : MethodBeforeAdvice &#123;</div><div class="line"></div><div class="line">    /**</div><div class="line">     * 在目标方法执行之前执行</div><div class="line">     * p0：method：目标方法</div><div class="line">     * p1：目标方法参数列表</div><div class="line">     * p2：目标对象</div><div class="line">     */</div><div class="line">    override fun before(p0: Method?, p1: Array&lt;out Any&gt;?, p2: Any?) &#123;</div><div class="line">        println(&quot;执行前置通知方法。&quot;)</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p><strong>AOP–后置通知–AfterReturningAdvice</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div></pre></td><td class="code"><pre><div class="line">  package AOP</div><div class="line"></div><div class="line">import org.springframework.aop.AfterReturningAdvice</div><div class="line">import java.lang.reflect.Method</div><div class="line"></div><div class="line">/**</div><div class="line"> * @author futao</div><div class="line"> * Created on 2017/10/16 - 14:10.</div><div class="line"> */</div><div class="line">class MyMethodAfterAdvice : AfterReturningAdvice &#123;</div><div class="line">    /**</div><div class="line">     * returnValue：目标方法的返回值</div><div class="line">     */</div><div class="line">    override fun afterReturning(returnValue: Any?, method: Method?, args: Array&lt;out Any&gt;?, target: Any?) &#123;</div><div class="line">        println(&quot;执行后置通知！&quot;)</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p><strong>环绕通知–MethodInterceptor</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div></pre></td><td class="code"><pre><div class="line">package AOP</div><div class="line"></div><div class="line">import org.aopalliance.intercept.MethodInterceptor</div><div class="line">import org.aopalliance.intercept.MethodInvocation</div><div class="line">import javax.rmi.CORBA.Util</div><div class="line"></div><div class="line">/**</div><div class="line"> * @author futao</div><div class="line"> * Created on 2017/10/16 - 14:32.</div><div class="line"> */</div><div class="line">/**</div><div class="line"> * 环绕通知</div><div class="line"> * 可以获取到目标方法的返回值，并且也能够修改目标方法的返回值</div><div class="line"> */</div><div class="line">class MyMethodInterceptor : MethodInterceptor &#123;</div><div class="line">    override fun invoke(p0: MethodInvocation?): Any &#123;</div><div class="line">        println(&quot;执行环绕通知，目标方法执行之前&quot;)</div><div class="line">        //执行目标方法</div><div class="line">        val proceed = p0!!.proceed()</div><div class="line">        println(&quot;执行环绕通知，目标方法执行之后&quot;)</div><div class="line"></div><div class="line">        //是目标方法的返回值</div><div class="line">        if (proceed != Unit &amp;&amp; proceed != null) &#123;</div><div class="line">            return proceed.toString().toUpperCase()</div><div class="line">        &#125;</div><div class="line">        return &quot;&quot;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p><strong>修改SomeServiceImpl</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div></pre></td><td class="code"><pre><div class="line">package Impl</div><div class="line"></div><div class="line">import `interface`.ISomeService</div><div class="line">import org.springframework.stereotype.Service</div><div class="line"></div><div class="line">/**</div><div class="line"> * Created by futao on 2017/10/13.</div><div class="line"> */</div><div class="line">@Service</div><div class="line">class SomeServiceImpl : ISomeService &#123;</div><div class="line">    override fun doFirst(): String &#123;</div><div class="line">        println(&quot;主业务逻辑代码 -- do first&quot;)</div><div class="line">        return &quot;abczQ&quot;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    override fun doSecond() &#123;</div><div class="line">        println(&quot;主业务逻辑代码 -- do second&quot;)</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p><strong>配置文件</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div></pre></td><td class="code"><pre><div class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</div><div class="line">&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;</div><div class="line">       xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</div><div class="line">       xmlns:context=&quot;http://www.springframework.org/schema/context&quot; xsi:schemaLocation=&quot;</div><div class="line">        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd</div><div class="line">        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd&quot;&gt;</div><div class="line">    &lt;!--↑↑增加context约束--&gt;</div><div class="line">    &lt;!--组件扫描器--&gt;</div><div class="line">    &lt;context:component-scan base-package=&quot;Impl&quot;/&gt;</div><div class="line"></div><div class="line">    &lt;!--注册通知--&gt;</div><div class="line">    &lt;bean id=&quot;myAdvice&quot; class=&quot;AOP.MyMethodBeforeAdvice&quot;/&gt;</div><div class="line">    &lt;!--生成代理对象--&gt;</div><div class="line">    &lt;bean id=&quot;serviceProxy&quot; class=&quot;org.springframework.aop.framework.ProxyFactoryBean&quot;&gt;</div><div class="line">        &lt;!--目标对象--&gt;</div><div class="line">        &lt;property name=&quot;target&quot; ref=&quot;someServiceImpl&quot;/&gt;</div><div class="line">        &lt;!--指定切面--&gt;</div><div class="line">        &lt;property name=&quot;interceptorNames&quot; value=&quot;myAdvice&quot;/&gt;</div><div class="line">    &lt;/bean&gt;</div><div class="line"></div><div class="line">    &lt;!--注册后置通知--&gt;</div><div class="line">    &lt;bean id=&quot;afterAdvice&quot; class=&quot;AOP.MyMethodAfterAdvice&quot;/&gt;</div><div class="line">    &lt;!--生成代理对象--&gt;</div><div class="line">    &lt;bean id=&quot;afterProxy&quot; class=&quot;org.springframework.aop.framework.ProxyFactoryBean&quot;&gt;</div><div class="line">        &lt;!--目标对象--&gt;</div><div class="line">        &lt;property name=&quot;target&quot; ref=&quot;someServiceImpl&quot;/&gt;</div><div class="line">        &lt;!--指定切面--&gt;</div><div class="line">        &lt;property name=&quot;interceptorNames&quot; value=&quot;afterAdvice&quot;/&gt;</div><div class="line">    &lt;/bean&gt;</div><div class="line"></div><div class="line">    &lt;!--环绕通知--&gt;</div><div class="line">    &lt;bean id=&quot;interceptorAdvice&quot; class=&quot;AOP.MyMethodInterceptor&quot;/&gt;</div><div class="line">    &lt;!--生成代理对象--&gt;</div><div class="line">    &lt;bean id=&quot;interceptorProxy&quot; class=&quot;org.springframework.aop.framework.ProxyFactoryBean&quot;&gt;</div><div class="line">        &lt;!--目标对象--&gt;</div><div class="line">        &lt;property name=&quot;target&quot; ref=&quot;someServiceImpl&quot;/&gt;</div><div class="line">        &lt;!--指定切面--&gt;</div><div class="line">        &lt;property name=&quot;interceptorNames&quot; value=&quot;interceptorAdvice&quot;/&gt;</div><div class="line">    &lt;/bean&gt;</div><div class="line">&lt;/beans&gt;</div></pre></td></tr></table></figure></p>
<p><strong>测试</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div></pre></td><td class="code"><pre><div class="line">import Impl.SomeServiceImpl</div><div class="line">import `interface`.ISomeService</div><div class="line">import com.google.gson.GsonBuilder</div><div class="line">import org.junit.Test</div><div class="line">import org.junit.runner.RunWith</div><div class="line">import org.springframework.context.support.ClassPathXmlApplicationContext</div><div class="line">import org.springframework.test.annotation.Rollback</div><div class="line">import org.springframework.test.context.ContextConfiguration</div><div class="line">import org.springframework.test.context.junit4.SpringJUnit4ClassRunner</div><div class="line">import javax.annotation.Resource</div><div class="line"></div><div class="line">/**</div><div class="line"> * Created by futao on 2017/10/13.</div><div class="line"> */</div><div class="line">@RunWith(SpringJUnit4ClassRunner::class)</div><div class="line">@ContextConfiguration(locations = arrayOf(&quot;classpath:applicationContext.xml&quot;))</div><div class="line">@Rollback</div><div class="line">class ForKotlin() &#123;</div><div class="line">    @Resource</div><div class="line">    val someServiceImpl: SomeServiceImpl? = null</div><div class="line"></div><div class="line"></div><div class="line">    @Test</div><div class="line">    fun testCase01() &#123;</div><div class="line">        val classPathXmlApplicationContext = ClassPathXmlApplicationContext(&quot;applicationContext.xml&quot;)</div><div class="line"></div><div class="line">//        前置通知</div><div class="line">        val someServiceImpl1 = classPathXmlApplicationContext.getBean(&quot;serviceProxy&quot;) as ISomeService</div><div class="line">        someServiceImpl1.doFirst()</div><div class="line">        someServiceImpl1.doSecond()</div><div class="line"></div><div class="line">        println(&quot;==============&quot;)</div><div class="line"></div><div class="line">        //后置通知</div><div class="line">        val iSomeService = classPathXmlApplicationContext.getBean(&quot;afterProxy&quot;) as ISomeService</div><div class="line">        iSomeService.doFirst()</div><div class="line">        iSomeService.doSecond()</div><div class="line"></div><div class="line">        println(&quot;----------------&quot;)</div><div class="line"></div><div class="line">        //环绕通知</div><div class="line">        val iSomeService1 = classPathXmlApplicationContext.getBean(&quot;interceptorProxy&quot;) as ISomeService</div><div class="line">        println(iSomeService1.doFirst())</div><div class="line">        println(iSomeService1.doSecond())</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p><strong>结果</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div></pre></td><td class="code"><pre><div class="line">执行前置通知方法。</div><div class="line">主业务逻辑代码 -- do first</div><div class="line">执行前置通知方法。</div><div class="line">主业务逻辑代码 -- do second</div><div class="line">==============</div><div class="line">主业务逻辑代码 -- do first</div><div class="line">执行后置通知！</div><div class="line">主业务逻辑代码 -- do second</div><div class="line">执行后置通知！</div><div class="line">----------------</div><div class="line">执行环绕通知，目标方法执行之前</div><div class="line">主业务逻辑代码 -- do first</div><div class="line">执行环绕通知，目标方法执行之后</div><div class="line">ABCZQ</div><div class="line">执行环绕通知，目标方法执行之前</div><div class="line">主业务逻辑代码 -- do second</div><div class="line">执行环绕通知，目标方法执行之后</div><div class="line">kotlin.Unit</div></pre></td></tr></table></figure></p>
<h2 id="异常通知–ExceptionAdvice"><a href="#异常通知–ExceptionAdvice" class="headerlink" title="异常通知–ExceptionAdvice"></a>异常通知–ExceptionAdvice</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line">package AOP</div><div class="line"></div><div class="line">import org.springframework.aop.ThrowsAdvice</div><div class="line"></div><div class="line"></div><div class="line">/**</div><div class="line"> * @author futao</div><div class="line"> * Created on 2017/10/16 - 15:03.</div><div class="line"> */</div><div class="line">class exceptionAdvice : ThrowsAdvice &#123;</div><div class="line">//    @Throws(Throwable::class)</div><div class="line">    fun afterThrowing(ex: Exception) &#123;</div><div class="line">        println(&quot;异常信息：$ex&quot;)</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p><strong>ServiceImpl</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div></pre></td><td class="code"><pre><div class="line">package Impl</div><div class="line"></div><div class="line">import `interface`.ISomeService</div><div class="line">import org.springframework.stereotype.Service</div><div class="line"></div><div class="line">/**</div><div class="line"> * Created by futao on 2017/10/13.</div><div class="line"> */</div><div class="line">@Service</div><div class="line">class SomeServiceImpl : ISomeService &#123;</div><div class="line">    override fun doFirst(): String &#123;</div><div class="line">        println(&quot;主业务逻辑代码 -- do first$&#123;1 / 0&#125;&quot;)</div><div class="line">        return &quot;abczQ&quot;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    override fun doSecond() &#123;</div><div class="line">        println(&quot;主业务逻辑代码 -- do second&quot;)</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p><strong>配置文件</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">&lt;!--异常代理--&gt;</div><div class="line">    &lt;bean id=&quot;exceptionAdvice&quot; class=&quot;AOP.exceptionAdvice&quot;/&gt;</div><div class="line">    &lt;!--生成代理对象--&gt;</div><div class="line">    &lt;bean id=&quot;exceptionProxy&quot; class=&quot;org.springframework.aop.framework.ProxyFactoryBean&quot;&gt;</div><div class="line">        &lt;!--目标对象--&gt;</div><div class="line">        &lt;property name=&quot;target&quot; ref=&quot;someServiceImpl&quot;/&gt;</div><div class="line">        &lt;!--指定切面--&gt;</div><div class="line">        &lt;property name=&quot;interceptorNames&quot; value=&quot;exceptionAdvice&quot;/&gt;</div><div class="line">    &lt;/bean&gt;</div></pre></td></tr></table></figure></p>
<p><strong>测试</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">//异常通知</div><div class="line">        val iSomeService2 = classPathXmlApplicationContext.getBean(&quot;exceptionProxy&quot;) as ISomeService</div><div class="line">        iSomeService2.doFirst()</div><div class="line">        iSomeService2.doSecond()</div></pre></td></tr></table></figure></p>
<p><strong>结果</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">异常信息：java.lang.ArithmeticException: / by zero</div></pre></td></tr></table></figure></p>
<hr>
<h1 id="顾问"><a href="#顾问" class="headerlink" title="顾问"></a>顾问</h1><h3 id="方法名匹配切入点顾问-建立在通知基础上-只需要修改配置文件"><a href="#方法名匹配切入点顾问-建立在通知基础上-只需要修改配置文件" class="headerlink" title="方法名匹配切入点顾问-建立在通知基础上-只需要修改配置文件"></a>方法名匹配切入点顾问-建立在通知基础上-只需要修改配置文件</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div></pre></td><td class="code"><pre><div class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</div><div class="line">&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;</div><div class="line">       xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</div><div class="line">       xmlns:context=&quot;http://www.springframework.org/schema/context&quot; xsi:schemaLocation=&quot;</div><div class="line">        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd</div><div class="line">        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd&quot;&gt;</div><div class="line">    &lt;!--↑↑增加context约束--&gt;</div><div class="line">    &lt;!--组件扫描器--&gt;</div><div class="line">    &lt;context:component-scan base-package=&quot;Impl&quot;/&gt;</div><div class="line"></div><div class="line">    &lt;!--注册前置通知--&gt;</div><div class="line">    &lt;bean id=&quot;myAdvice&quot; class=&quot;AOP.Advice.MyMethodBeforeAdvice&quot;/&gt;</div><div class="line">    &lt;!--注册顾问--&gt;</div><div class="line">    &lt;bean id=&quot;myAdvisor&quot; class=&quot;org.springframework.aop.support.NameMatchMethodPointcutAdvisor&quot;&gt;</div><div class="line">        &lt;!--指定在哪个通知上进行修改--&gt;</div><div class="line">        &lt;property name=&quot;advice&quot; ref=&quot;myAdvice&quot;/&gt;</div><div class="line">         &lt;!--匹配的对象是简单方法名（不包含类名和包名，只有方法名）--&gt;</div><div class="line">        &lt;!--指定哪个或者哪些连接点作为切入点--&gt;</div><div class="line">        &lt;property name=&quot;mappedName&quot; value=&quot;doThird&quot;/&gt;</div><div class="line">        &lt;!--多个切入点--&gt;</div><div class="line">        &lt;property name=&quot;mappedNames&quot; value=&quot;doSecond,doThird&quot;/&gt;</div><div class="line">    &lt;/bean&gt;</div><div class="line">    &lt;!--生成代理对象--&gt;</div><div class="line">    &lt;bean id=&quot;serviceProxy&quot; class=&quot;org.springframework.aop.framework.ProxyFactoryBean&quot;&gt;</div><div class="line">        &lt;!--目标对象--&gt;</div><div class="line">        &lt;property name=&quot;target&quot; ref=&quot;someServiceImpl&quot;/&gt;</div><div class="line">        &lt;!--指定切面，修改为顾问--&gt;</div><div class="line">        &lt;property name=&quot;interceptorNames&quot; value=&quot;myAdvisor&quot;/&gt;</div><div class="line">    &lt;/bean&gt;</div><div class="line">&lt;/beans&gt;</div></pre></td></tr></table></figure>
<h3 id="正则表达式方法切入点顾问-在通知的基础上-只需要修改配置文件"><a href="#正则表达式方法切入点顾问-在通知的基础上-只需要修改配置文件" class="headerlink" title="正则表达式方法切入点顾问-在通知的基础上-只需要修改配置文件"></a>正则表达式方法切入点顾问-在通知的基础上-只需要修改配置文件</h3><p><code>pattern</code>的配置需要具体百度<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div></pre></td><td class="code"><pre><div class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</div><div class="line">&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;</div><div class="line">       xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</div><div class="line">       xmlns:context=&quot;http://www.springframework.org/schema/context&quot; xsi:schemaLocation=&quot;</div><div class="line">        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd</div><div class="line">        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd&quot;&gt;</div><div class="line">    &lt;!--↑↑增加context约束--&gt;</div><div class="line">    &lt;!--组件扫描器--&gt;</div><div class="line">    &lt;context:component-scan base-package=&quot;Impl&quot;/&gt;</div><div class="line"></div><div class="line">    &lt;!--注册前置通知--&gt;</div><div class="line">    &lt;bean id=&quot;myAdvice&quot; class=&quot;AOP.Advice.MyMethodBeforeAdvice&quot;/&gt;</div><div class="line"></div><div class="line">    &lt;!--正则表达式匹配切入点顾问--&gt;</div><div class="line">    &lt;bean id=&quot;myAdvisor&quot; class=&quot;org.springframework.aop.support.RegexpMethodPointcutAdvisor&quot;&gt;</div><div class="line">        &lt;property name=&quot;advice&quot; ref=&quot;myAdvice&quot;/&gt;</div><div class="line">        &lt;!--匹配的对象是全限定方法名（包含类名和包名）--&gt;</div><div class="line">        &lt;property name=&quot;pattern&quot; value=&quot;.*ir.*&quot;/&gt;</div><div class="line">    &lt;/bean&gt;</div><div class="line">    &lt;!--生成代理对象--&gt;</div><div class="line">    &lt;bean id=&quot;serviceProxy&quot; class=&quot;org.springframework.aop.framework.ProxyFactoryBean&quot;&gt;</div><div class="line">        &lt;!--目标对象--&gt;</div><div class="line">        &lt;property name=&quot;target&quot; ref=&quot;someServiceImpl&quot;/&gt;</div><div class="line">        &lt;!--指定切面，修改为顾问--&gt;</div><div class="line">        &lt;property name=&quot;interceptorNames&quot; value=&quot;myAdvisor&quot;/&gt;</div><div class="line">    &lt;/bean&gt;</div><div class="line">&lt;/beans&gt;</div></pre></td></tr></table></figure></p>
<h3 id="默认Advisor自动代理生成器-DefaultAdvisorAutoProxyCreator"><a href="#默认Advisor自动代理生成器-DefaultAdvisorAutoProxyCreator" class="headerlink" title="默认Advisor自动代理生成器-DefaultAdvisorAutoProxyCreator"></a>默认Advisor自动代理生成器-DefaultAdvisorAutoProxyCreator</h3><blockquote>
<p>特点:<br>1.切面默认只能是顾问Advisor<br>2.所有在配置文件中注册的Bean都作为目标对象<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div></pre></td><td class="code"><pre><div class="line"> &lt;!--正则表达式匹配切入点顾问--&gt;</div><div class="line">    &lt;bean id=&quot;myAdvisor&quot; class=&quot;org.springframework.aop.support.RegexpMethodPointcutAdvisor&quot;&gt;</div><div class="line">        &lt;property name=&quot;advice&quot; ref=&quot;myAdvice&quot;/&gt;</div><div class="line">        &lt;!--匹配的对象是全限定方法名（包含类名和包名）--&gt;</div><div class="line">        &lt;property name=&quot;pattern&quot; value=&quot;.*ir.*&quot;/&gt;</div><div class="line">    &lt;/bean&gt;</div><div class="line">&lt;!--生成代理对象--&gt;</div><div class="line">    &lt;!--&lt;bean id=&quot;serviceProxy&quot; class=&quot;org.springframework.aop.framework.ProxyFactoryBean&quot;&gt;--&gt;</div><div class="line">    &lt;!--&amp;lt;!&amp;ndash;目标对象&amp;ndash;&amp;gt;--&gt;</div><div class="line">    &lt;!--&lt;property name=&quot;target&quot; ref=&quot;someServiceImpl&quot;/&gt;--&gt;</div><div class="line">    &lt;!--&amp;lt;!&amp;ndash;指定切面，修改为顾问&amp;ndash;&amp;gt;--&gt;</div><div class="line">    &lt;!--&lt;property name=&quot;interceptorNames&quot; value=&quot;myAdvisor&quot;/&gt;--&gt;</div><div class="line">    &lt;!--&lt;/bean&gt;--&gt;</div><div class="line"></div><div class="line">    &lt;!--注册默认Advisor自动代理生成器-。实际上实现了Bean后处理器--&gt;</div><div class="line">    &lt;bean class=&quot;org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator&quot;/&gt;</div></pre></td></tr></table></figure></p>
</blockquote>
<h3 id="Bean名称自动代理生成器-BeanNameAutoProxyCreator"><a href="#Bean名称自动代理生成器-BeanNameAutoProxyCreator" class="headerlink" title="Bean名称自动代理生成器-BeanNameAutoProxyCreator"></a>Bean名称自动代理生成器-BeanNameAutoProxyCreator</h3><blockquote>
<p>特点：<br>1.可以指定要增强的目标对象bean<br>2.切面可以是顾问也可以是通知<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">&lt;bean class=&quot;org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator&quot;&gt;</div><div class="line">     &lt;!--指定bean--&gt;</div><div class="line">     &lt;property name=&quot;beanNames&quot; value=&quot;someServiceImpl&quot;/&gt;</div><div class="line">     &lt;!--指定切面--&gt;</div><div class="line">     &lt;property name=&quot;interceptorNames&quot; value=&quot;myAdvisor&quot;/&gt;</div><div class="line"> &lt;/bean&gt;</div></pre></td></tr></table></figure></p>
</blockquote>
<h2 id="tips"><a href="#tips" class="headerlink" title="tips"></a>tips</h2><p><strong>测试报错：</strong><code>java.lang.IllegalStateException: Could not load TestContextBootstrapper [null]. Specify @BootstrapWi</code><br>错误原因：<br>在使用spring-test插件执行单元测试时，需要注意的是spring的版本应该与spring-test的版本一致，否则在执行junit测试时就会出现<code>&quot;Java.lang.IllegalStateException&quot;</code></p>

    </div>
    <p class="post-meta">
        <span class="post-cat">分类：
            <a class="cat-link" href="/coder957/categories/Java/">Java</a>|<a class="cat-link" href="/coder957/categories/Java/Spring/">Spring</a>
        </span>
        <span class="post-tags">
            标签：
            
    
        <a href="/coder957/tags/Java/" title="Java">Java</a> / 
    
        <a href="/coder957/tags/Spring/" title="Spring">Spring</a> / 
    
        <a href="/coder957/tags/kotlin/" title="kotlin">kotlin</a>
    

        </span>
    </p>
</article>
<!-- 分享按钮 -->

  <div class="article-share clearfix text-center">
    <div class="share-area">
      <span class="share-txt">分享到：</span>
      <a href="javascript: window.open('http://service.weibo.com/share/share.php?url=' + encodeURIComponent(location.href) + '&title=' + document.title + '&language=zh_cn');" class="share-icon weibo"></a>
      <a href="javascript: alert('请复制链接到微信并发送');" class="share-icon wechat"></a>
      <a href="javascript: window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + encodeURIComponent(location.href) + '&title=' + document.title);" class="share-icon qqzone"></a>
      <a href="javascript: window.open('http://connect.qq.com/widget/shareqq/index.html?url=' + encodeURIComponent(location.href) + '&desc=Jelon个人博客&title=' + document.title + '&callback=' + encodeURIComponent(location.href));" class="share-icon qq"></a>
      <a href="javascript: window.open('http://shuo.douban.com/!service/share?href=' + encodeURIComponent(location.href) + '&name=' + document.title + '&text=' + document.title);" class="share-icon douban"></a>
    </div>
  </div>


    <!-- 上一篇/下一篇 -->

<div class="article-nav clearfix">
    
    <span class="prev fl">
        上一篇<br >
        <a href="/coder957/2017/10/16/基于Spring环境的AOP-Aspectj/">
            
                基于Spring环境的AOP-Aspectj-基于Annotation
            
        </a>
    </span>
    

    
    <span class="next fr">
        下一篇<br >
        <a href="/coder957/2017/10/13/基于Annotation的DI-01/">
            
                基于Annotation的DI-01
            
        </a>
    </span>
    
</div>

        <!-- 文章评论 -->
        
  <script src="/coder957/js/comment.js"></script>
  <div id="comments" class="comment">
    <!--
    <div class="sign-bar">
      GitHub 已登录!
      <span class="sign-link">登出</span>
    </div>
    <section class="box">
      <div class="com-avatar"><img src="/img/jelon.jpg" alt="avatar"></div>
      <div class="com-text">
        <div class="main">
          <textarea class="text-area-edited show" placeholder="欢迎评论！"></textarea>
          <div class="text-area-preview"></div>
        </div>
        <div class="switch">
          <div class="switch-item on">编辑</div>
          <div class="switch-item">预览</div>
        </div>
        <div class="button">提交</div>
      </div>
    </section>
    <section class="tips">注：评论支持 markdown 语法！</section>
    <section class="list-wrap">
      <ul class="list">
        <li>
          <div class="user-avatar">
            <a href="/">
              <img src="/img/jelon.jpg" alt="user-avatar">
            </a>
          </div>
          <div class="user-comment">
            <div class="user-comment-header">
              <span class="post-name">张德龙</span>
              <span class="post-time">2017年12月12日</span>
              <span class="like liked">已赞</span>
              <span class="like-num">2</span>
            </div>
            <div class="user-comment-body">333333</div>
          </div>
        </li>
        <li>
          <div class="user-avatar">
            <a href="/">
              <img src="/img/jelon.jpg" alt="user-avatar">
            </a>
          </div>
          <div class="user-comment">
            <div class="user-comment-header">
              <span class="post-name">刘德华</span>
              <span class="post-time">2017年12月12日</span>
              <span class="like">点赞</span>
              <span class="like-num">2</span>
            </div>
            <div class="user-comment-body">vvvvv</div>
          </div>
        </li>
      </ul>
      <div class="page-nav">
        <a href="javascript: void(0);" class="item">1</a>
        <a href="javascript: void(0);" class="item">2</a>
        <a href="javascript: void(0);" class="item current">3</a>
      </div>
    </section>
    -->
  </div>
  <script>
  JELON.Comment({
    container: 'comments',
    label: 'AOP' || '2017/10/13/AOP/',
    owner: 'FutaoSmile',
    repo: 'blog_comments',
    clientId: '149ec394071cfd7f0f47',
    clientSecret: 'd1c988f53efa3f0f8651799f8212cc8e2cab24b9'
  });
  </script>


            </div>

        </section>
        <!-- 侧栏部分 -->
<aside class="sidebar">
    <section class="widget">
        <h3 class="widget-hd"><strong>文章分类</strong></h3>
        <!-- 文章分类 -->
<ul class="widget-bd">
    
    <li>
        <a href="/coder957/categories/后端/">后端</a>
        <span class="badge">(5)</span>
    </li>
    
    <li>
        <a href="/coder957/categories/Java/">Java</a>
        <span class="badge">(8)</span>
    </li>
    
    <li>
        <a href="/coder957/categories/Web技术/">Web技术</a>
        <span class="badge">(3)</span>
    </li>
    
    <li>
        <a href="/coder957/categories/后端/Java/">Java</a>
        <span class="badge">(5)</span>
    </li>
    
    <li>
        <a href="/coder957/categories/GIt/">GIt</a>
        <span class="badge">(1)</span>
    </li>
    
    <li>
        <a href="/coder957/categories/Java/Spring/">Spring</a>
        <span class="badge">(3)</span>
    </li>
    
    <li>
        <a href="/coder957/categories/Java/学习/">学习</a>
        <span class="badge">(5)</span>
    </li>
    
    <li>
        <a href="/coder957/categories/Web技术/Java/">Java</a>
        <span class="badge">(1)</span>
    </li>
    
    <li>
        <a href="/coder957/categories/Web技术/Kotlin/">Kotlin</a>
        <span class="badge">(1)</span>
    </li>
    
    <li>
        <a href="/coder957/categories/GIt/Web技术/">Web技术</a>
        <span class="badge">(1)</span>
    </li>
    
    <li>
        <a href="/coder957/categories/学习/">学习</a>
        <span class="badge">(1)</span>
    </li>
    
</ul>
    </section>

    
    <section class="widget">
        <h3 class="widget-hd"><strong>热门标签</strong></h3>
        <!-- 文章标签 -->
<div class="widget-bd tag-wrap">
  
    <a class="tag-item" href="/coder957/tags/Java/" title="Java">Java (12)</a>
  
    <a class="tag-item" href="/coder957/tags/Spring/" title="Spring">Spring (9)</a>
  
    <a class="tag-item" href="/coder957/tags/kotlin/" title="kotlin">kotlin (7)</a>
  
    <a class="tag-item" href="/coder957/tags/Maven/" title="Maven">Maven (2)</a>
  
    <a class="tag-item" href="/coder957/tags/Hibernate/" title="Hibernate">Hibernate (2)</a>
  
    <a class="tag-item" href="/coder957/tags/kotlin-小知识/" title="kotlin 小知识">kotlin 小知识 (1)</a>
  
    <a class="tag-item" href="/coder957/tags/Kotlin/" title="Kotlin">Kotlin (1)</a>
  
    <a class="tag-item" href="/coder957/tags/Json/" title="Json">Json (1)</a>
  
    <a class="tag-item" href="/coder957/tags/热点文章/" title="热点文章">热点文章 (1)</a>
  
    <a class="tag-item" href="/coder957/tags/博主推荐/" title="博主推荐">博主推荐 (1)</a>
  
    <a class="tag-item" href="/coder957/tags/转载/" title="转载">转载 (1)</a>
  
    <a class="tag-item" href="/coder957/tags/资料/" title="资料">资料 (1)</a>
  
    <a class="tag-item" href="/coder957/tags/Ajax/" title="Ajax">Ajax (1)</a>
  
</div>
    </section>
    

    

    
    <!-- 友情链接 -->
    <section class="widget">
        <h3 class="widget-hd"><strong>友情链接</strong></h3>
        <!-- 文章分类 -->
<ul class="widget-bd">
    
        <li>
            <a href="http://lsc95.github.io/" target="_blank" title="椿哥的狗窝">椿哥的狗窝</a>
        </li>
    
        <li>
            <a href="http://futaosmile.oschina.io/documents/" target="_blank" title="donot click me">Document</a>
        </li>
    
        <li>
            <a href="" target="_blank" title="虚位以待">loading...</a>
        </li>
    
</ul>
    </section>
    
</aside>
<!-- / 侧栏部分 -->
    </div>

    <!-- 博客底部 -->
    <footer class="footer">
    &copy;
    
                2016-
                2017
                    

                        <a href="/coder957/">Loves You</a>
</footer>
<div class="back-to-top" id="JELON__backToTop" title="返回顶部">返回顶部</div>
    <!--博客js脚本 -->
    <!-- 这里放网站js脚本 -->
<script src="/coder957/js/main.js"></script>
</body>
</html>